#include "bullet.h"

Bullet::Bullet()
{
    //初始化加载子弹图片
    m_Bullet.load(BULLET_PATH);
    //子弹坐标
    m_X=-GAME_WIDTH;
    m_Y=GAME_HEIGHT*0.5-m_Bullet.height()*0.5;
    //子弹状态
    m_Free=true;
    //子弹速度
    m_Speed=BULLET_SPEED;
    //子弹边框
    m_Rect.setWidth(m_Bullet.width());
    m_Rect.setHeight(m_Bullet.height());
    m_Rect.moveTo(m_X,m_Y);
}

void Bullet::updatePosition()
{
//空闲的子弹
    if(m_Free)
    {
        return;
    }
//移动的子弹
    m_X+=m_Speed;
    m_Rect.moveTo(m_X,m_Y);
    if(m_X>=GAME_WIDTH)
    {
        m_Free=true;
    }
}
